
<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>药品信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input name="id" th:value="${druginfo?.id}" type="hidden">
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>药品名称
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${druginfo?.name}" name="name" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入药品名称">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>供应商名称
                </label>
                <div class="layui-input-block">
                    <select name="supplier" id="supplier"></select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>保质期（月）
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${druginfo?.warrenty}" name="warrenty" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入保质期">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>药品编号
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${druginfo?.number}" name="number" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入药品编号">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>药品价格
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${druginfo?.price}" name="price" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入药品价格">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>库存
                </label>
                <div class="layui-input-block">
                    <input type="text" th:value="${druginfo?.stock}" name="stock" lay-verify="required"
                           autocomplete="off" class="layui-input" placeholder="请输入药品库存">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>生产时间
                </label>
                <div class="layui-input-block">
                    <input type="text" readonly class="layui-input" th:value="${druginfo?.dateFormat}" name="producttime" id="date" placeholder="yyyy-MM-dd">
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="LAY-front-submit" id="LAY-front-submit" value="确认">
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form','laydate'], function() {
        $ = layui.jquery;
        var form = layui.form;
        var laydate = layui.laydate;

        //日期小插件
        laydate.render({
            elem: '#date',
            trigger: 'click'
        });

        //当前供应商的值
        var currentSupplier = '[[${druginfo?.supplier}]]';
        //获取所有供应商列表
        $.ajax({
            url:'/supplier/supplierList',
            dataType:'json',
            success:function (data){
                $('#supplier').prepend('<option>请选择供应商名称</option>');
                for (var i = 0; i < data.length;i++){
                    if(currentSupplier == data[i].name){
                        $('#supplier').append('<option selected value="'+data[i].name+'">'+data[i].name+'</option>')
                    }else {
                        $('#supplier').append('<option value="'+data[i].name+'">'+data[i].name+'</option>')
                    }

                }
                form.render(); //下拉列表渲染，把内容加载进去
            }
        });

    });
</script>
</body>

</html>
